package com.crm.controller;

import com.crm.domain.dto.ContractDto;
import com.crm.domain.dto.ReportDto;
import com.crm.domain.entity.*;
import com.crm.domain.vo.DataVO;
import com.crm.domain.vo.LineChartVO;
import com.crm.domain.vo.OneVO;
import com.crm.domain.vo.RowsVO;
import com.crm.service.ReportService;
import org.jdom2.output.support.SAXOutputProcessor;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/report")
public class ReportController {
    @Resource
    private ReportService reportService;

    @GetMapping("/cluesStatisticsList")
    public RowsVO getCluesStatisticsList(ReportDto dto) {
        RowsVO<Report> vo = reportService.select(dto);
        return vo;
    }


    /**
     * 线索转化率漏斗图
     * @param beginCreateTime 开始时间
     * @param endCreateTime 结束时间
     * @return
     */
    //http://localhost/dev-api/report/getVulnerabilityMap/2022-09-27/2022-10-04
    @GetMapping("/getVulnerabilityMap/{beginCreateTime}/{endCreateTime}")
    public OneVO getVulnerabilityMap(@PathVariable String beginCreateTime, @PathVariable String endCreateTime){
        OneVO vo = reportService.getVulnerabilityMap(beginCreateTime,endCreateTime);
        return vo;
    }

    /**
     * 学科客户分布饼图
     * @return
     */
    @GetMapping("/subjectStatistics/{beginCreateTime}/{endCreateTime}")
    public DataVO subjectStatistics(@PathVariable String beginCreateTime, @PathVariable String endCreateTime){
        DataVO vo = reportService.subjectStatistics(beginCreateTime,endCreateTime);
        return vo;
    }

    /**
     * 线索统计折线图
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/cluesStatistics/{beginCreateTime}/{endCreateTime}")
    public LineChartVO cluesStatistics(@PathVariable String beginCreateTime, @PathVariable String endCreateTime){
        return reportService.cluesStatistics(beginCreateTime,endCreateTime);
    }

    /**
     * 客户管理数据
     * @param dto
     * @return
     */
    @GetMapping("contractStatisticsList")
    public RowsVO getContractStatisticsList(ContractDto dto){
        RowsVO<ReportContract> vo = reportService.selectContract(dto);
        return vo;
    }




    /**
     * 客户管理折现统计图
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/contractStatistics/{beginCreateTime}/{endCreateTime}")
    public LineChartVO contractStatistics(@PathVariable String beginCreateTime, @PathVariable String endCreateTime){
        return reportService.contractStatistics(beginCreateTime,endCreateTime);
    }

    /**
     * 销售统计折线图
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/salesStatistics/{beginCreateTime}/{endCreateTime}")
    public LineChartVO salesStatistics(@PathVariable String beginCreateTime, @PathVariable String endCreateTime){
        return reportService.salesStatistics(beginCreateTime,endCreateTime);
    }

    /**
     *渠道数据统计
     */
    @GetMapping("activityStatisticsList")
    public RowsVO activityStatisticsList(Chll dto){
        RowsVO<Chll> vo = reportService.selectActive(dto);
        return vo;
    }

}
